package com.yeyuanqi.web.scheduletask;

import com.yeyuanqi.dao.StatisticMapper;
import com.yeyuanqi.untils.MailUtils;
import com.yeyuanqi.untils.PythonUntils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Component;

@Component
public class ScheduleTask {

    @Autowired
    private StatisticMapper statisticMapper;
    @Autowired
    private MailUtils mailUtils;
    @Autowired
    private PythonUntils pythonUntils;
    @Value("${spring.mail.username}")
    private  String mailto;

//    @Scheduled(cron = "0 */3 * * * ?")
//    public void sendEmail(){
//        long totalvisit = statisticMapper.getTotalVisit();
//        long totalComment = statisticMapper.getTotalComment();
//        StringBuffer content = new StringBuffer();
//        content.append("博客总访问量："+totalvisit+"人次").append("\n");
//        content.append("博客总评论量："+totalComment+"人次").append("\n");
//        mailUtils.sendSimpleEmail(mailto,"个人博客浏览统计数据",content.toString());
//    }

////    腾讯新闻热搜约15分钟获取一次
//    @Scheduled(cron = "0 0/10 * * * *")
//    public void bilibilipy(){
//        pythonUntils.starttengxunxinwen();
//    }
//
////    微博热搜5分钟获取一次
//    @Scheduled(cron = "0 0/5 * * * *")
//    public void weibopy(){
//        pythonUntils.startweibo();
//    }
//
//    //    百度热搜5分钟获取一次
//    @Scheduled(cron = "0 0/5 * * * *")
//    public void baidupy(){
//        pythonUntils.startbaidu();
//    }
//
//    //    今日头条热搜10分钟获取一次
//    @Scheduled(cron = "0 0/10 * * * *")
//    public void jinritoutiaopy(){
//        pythonUntils.startjinritoutiao();
//    }

}
